package jrain.flow.engine.bean;

import java.util.ArrayList;
import java.util.List;

public class NodeDef {

	private FlowDef flowDef;
	private String code;
	private String name;
	private String nodeType;
	private String splitType;
	private String joinType;
	private List<ConnDef> inputs = new ArrayList<>();
	private List<ConnDef> ouputs = new ArrayList<>();

	public FlowDef getFlowDef() {
		return flowDef;
	}

	public void setFlowDef(FlowDef flowDef) {
		if(code != null && code.length() > 0){
			this.inputs.clear();
			this.ouputs.clear();
			this.inputs.addAll(flowDef.getConnDefByTid(code));
			this.ouputs.addAll(flowDef.getConnDefBySid(code));
			this.inputs.forEach(connDef->{
				connDef.setTnode(this);
			});
			this.ouputs.forEach(connDef->{
				connDef.setSnode(this);
			});
		}
		this.flowDef = flowDef;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	
	public String getNodeType() {
		return nodeType;
	}

	public void setNodeType(String nodeType) {
		this.nodeType = nodeType;
	}

	public String getSplitType() {
		return splitType;
	}

	public void setSplitType(String splitType) {
		this.splitType = splitType;
	}

	public String getJoinType() {
		return joinType;
	}

	public void setJoinType(String joinType) {
		this.joinType = joinType;
	}

	public List<ConnDef> getOuputs() {
		return ouputs;
	}

	public void addOutput(ConnDef connDef) {
		this.ouputs.add(connDef);
	}

	public List<ConnDef> getInputs() {
		return inputs;
	}

	public void addInput(ConnDef connDef) {
		this.inputs.add(connDef);
	}

}
